package com.imooc.coupon.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * @description:
 * @author：naxiaozi，微信：naxiaozi
 * @date: 2025/8/10
 * @Copyright：
 * @AllArgsConstructor 全参构造函数
 * @Getter getter属性
 */
@Getter
@AllArgsConstructor
public enum CouponCategory {
    //定于优惠券枚举类型
    MANJIAN("满减券","001"),
    ZHEKOU("折扣券","002"),
    LIANJIAN("立减券","003");

    //优惠券描述
    private String description;
    //优惠券编码
    private String code;

    public static CouponCategory of(String code){
        Objects.requireNonNull(code);
        return Stream.of(values()).
                filter(bean->bean.code.equals(code))
                .findAny()
                .orElseThrow(()->new IllegalArgumentException(code+" not exists"));
    }
}
